/*
 * @lc app=leetcode.cn id=762 lang=cpp
 *
 * [762] 二进制表示中质数个计算置位
 */

// @lc code=start
class Solution {
public:
    bool isPrime(int n ) {
        if(n < 2) {
            return false;
        }
        for(int i = 2;i <= pow(n,0.5);i++) {
            if(n % i == 0) {
                return false;
            }
        }
        return true;
    }
    int bitOneCount(int n) {
        int count = 0;
        while(n) {
            count++;
            n = n & (n-1);
        }
        return count;
    }
    int countPrimeSetBits(int left, int right) {
        int ret = 0;
        for(int i = left;i <= right;i++) {
            ret += isPrime(bitOneCount(i));
        }
        return ret;
    }
};
// @lc code=end

